<!DOCTYPE html>
<html lang="en" class="page-fill" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>添加单号规则</title>
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="/css/oksub.css">
	<link rel="stylesheet" href="/layui/css/layui.css">
	<script type="text/javascript" src="/lib/loading/okLoading.js"></script>
</head>
<body>
	<div class="ok-body">
		<!--form表单-->
		<form class="layui-form layui-form-pane ok-form" lay-filter="filter">

			<div class="layui-form-item">
					<label class="layui-form-label">类型</label>
					<div class="layui-input-block">
						<select name="parentNetworkId" lay-verify="required" lay-search id="parentNetworkId">
							<option value="">请选择发放网点</option>
							<option th:each="net:${networks}" th:value="${net.networkId}" th:text="${net.networkName}"></option>
						</select>
					</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">开始单号</label>
				<div class="layui-input-block">
					<input type="text" name="startOddId" id="startOddId" placeholder="请输入开始单号"
						   th:value="${maxWayBillId}"   autocomplete="off" class="layui-input" lay-verify="required" readonly="readonly">
				</div>
			</div>

			<div class="layui-form-item">
				<label class="layui-form-label">发放数量</label>
				<div class="layui-input-block">
					<input type="text" name="grantOrderNumber" placeholder="请输入发放数量" id="grantOrderNumber"
						autocomplete="off" class="layui-input" lay-verify="required">
				</div>
			</div>

			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">备注</label>
				<div class="layui-input-block">
					<textarea name="remark" placeholder="请输入备注" id="remark" class="layui-textarea"></textarea>
				</div>
			</div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn" lay-submit lay-filter="add">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>

		</form>
	</div>
	
	<!--js逻辑-->
	<script src="/lib/layui/layui.js"></script>
	<script>

		layui.use(["element", "form", "laydate", "okLayer", "okUtils","jquery"], function () {
			var form = layui.form;
			var okLayer = layui.okLayer;
			var okUtils = layui.okUtils;
			var $ = layui.jquery;
			okLoading.close();

				form.on("submit(add)", function (data) {

					console.info(data.field);
					okUtils.ajax("/api/orderNumberList/add", "post", data.field, true).done(function (response) {
						console.log(response);
						okLayer.greenTickMsg("操作成功", function () {
							// 刷新父页面  window.parent.opener.location.reload();
							parent.layer.close(parent.layer.getFrameIndex(window.name));
						});
					}).fail(function (error) {
						layer.msg("不符合规则", {icon: 2, time: 2000});
						console.log(error);
					});
					return false;
				});
		});
	</script>
</body>
</html>